﻿@using BlazorComponent.I18n
@namespace ChatGpt.Shared
@inject I18n I18n

<PModal Value=Value
        ValueChanged="ValueChanged"
        Persistent
        Title="@I18n.T("Setting.Title")"
        Width="500"
        SaveText="@I18n.T("Setting.SaveText")"
        CancelText="@I18n.T("Setting.CancelText")"
        OnSave="OnSave"
        OnCancel="OnCancel">
    <ActivatorContent>
        <MListItem @attributes="@context.Attrs">
            <MListItemContent>
                <MListItemTitle>
                    @I18n.T("Setting")
                </MListItemTitle>
            </MListItemContent>
        </MListItem>
    </ActivatorContent>
    <ChildContent>
        <MRow>
            <MCol Cols="12">
                <MTooltip Top>
                    <ActivatorContent>
                        <MRadioGroup @attributes="@context.Attrs" @bind-Value="ChatGptOptions.Model"
                                              Column>
                            <MRadio Label="@I18n.T("Setting.ModelType.ChatGpt")"
                                    Value="ModelType.ChatGpt">
                            </MRadio>
                            <MRadio Label="@I18n.T("Setting.ModelType.DALLE")"
                                    Value="ModelType.DALLE">
                            </MRadio>
                        </MRadioGroup>
                    </ActivatorContent>
                    <ChildContent>
                        @I18n.T("Setting.ModelType.Hint")
                    </ChildContent>
                </MTooltip>

            </MCol>

            <MCol Cols="12">

                <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.Token"
                                    Label="Token"
                                            Dense
                                            Outlined
                                    HideDetails="@("auto")" />
                    </ActivatorContent>
                    <ChildContent>
                        @I18n.T("Setting.Token.Hint")
                    </ChildContent>
                </MTooltip>
            </MCol>

            @if (ChatGptOptions.Model == ModelType.ChatGpt)
            {

                <MCol Cols="12">
                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.HttpUrl"
                                    Label="ChatGpt3.5API"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.HttpUrl.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>
                <MCol Cols="12">
                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.MaxTokens"
                                    Label="@I18n.T("Setting.ChatGpt.MaxTokens.Label")"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.MaxTokens.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>

                <MCol Cols="12">
                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.Temperature"
                                    Label="@I18n.T("Setting.ChatGpt.Temperature.Label")"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.Temperature.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>


                <MCol Cols="12">

                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.System"
                                    Label="@I18n.T("Setting.ChatGpt.System.Label")"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.System.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>

                <MCol Cols="12">

                    <MTooltip Top>
                    <ActivatorContent>
                        <MSwitch @attributes="@context.Attrs" @bind-Value="ChatGptOptions.InContext"
                                 Label="@(ChatGptOptions.InContext ? @I18n.T("Setting.ChatGpt.InContext.Label.Disabled") :  @I18n.T("Setting.ChatGpt.InContext.Label.Enable"))">
                        </MSwitch>
                    </ActivatorContent>
                    <ChildContent>
                        @I18n.T("Setting.ChatGpt.InContext.Hint")
                    </ChildContent>
                </MTooltip>
            </MCol>

                @if (ChatGptOptions.InContext)
                {
                    <MCol Cols="12">

                        <MTooltip Top>
                        <ActivatorContent>
                            <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.InContextMaxMessage"
                                        Label="@I18n.T("Setting.ChatGpt.InContextMaxMessage.Label")"
                                                    Dense
                                                    Outlined
                                            HideDetails="@("auto")" />
                            </ActivatorContent>
                            <ChildContent>
                                @I18n.T("Setting.ChatGpt.InContextMaxMessage.Hint")
                            </ChildContent>
                        </MTooltip>
                    </MCol>

                    <MCol Cols="12">

                        <MTooltip Top>
                        <ActivatorContent>
                            <MSwitch @attributes="@context.Attrs" @bind-Value="ChatGptOptions.CarryChatGptMessage"
                                     Label="@(ChatGptOptions.CarryChatGptMessage ?
                                                @I18n.T("Setting.ChatGpt.CarryChatGptMessage.Label.Enable") :
                                                @I18n.T("Setting.ChatGpt.CarryChatGptMessage.Label.Disabled"))">
                            </MSwitch>
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.CarryChatGptMessage.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>
                }
            }
            else if (ModelType.DALLE == ChatGptOptions.Model)
            {
                <MCol Cols="12">

                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.DDLLEHttpUrl"
                                    Label="@I18n.T("Setting.ChatGpt.DDLLEHttpUrl.Label")"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.DDLLEHttpUrl.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>
                <MCol Cols="12">
                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.DDLLEWidth"
                                    Label="@I18n.T("Setting.ChatGpt.DDLLEWidth.Label")"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.DDLLEWidth.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>
                <MCol Cols="12">
                    <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.DDLLEHeight"
                                    Label="@I18n.T("Setting.ChatGpt.DDLLEHeight.Label")"
                                                Dense
                                                Outlined
                                        HideDetails="@("auto")" />
                        </ActivatorContent>
                        <ChildContent>
                            @I18n.T("Setting.ChatGpt.DDLLEHeight.Hint")
                        </ChildContent>
                    </MTooltip>
                </MCol>
            }

            <MDivider>@I18n.T("Setting.BasicSetting.Label")</MDivider>
            <MCol Cols="12">
                <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.Avatar"
                                    Label="@I18n.T("Setting.Avatar.Label")"
                                            Dense
                                            Outlined
                                    HideDetails="@("auto")" />
                    </ActivatorContent>
                    <ChildContent>
                        @I18n.T("Setting.Avatar.Hint")
                    </ChildContent>
                </MTooltip>
            </MCol>
            <MCol Cols="12">
                <MTooltip Top>
                    <ActivatorContent>
                        <MTextField @attributes="@context.Attrs" @bind-Value="ChatGptOptions.ChatGptAvatar"
                                    Label="@I18n.T("Setting.ChatGptAvatar.Label")"
                                            Dense
                                            Outlined
                                    HideDetails="@("auto")" />
                    </ActivatorContent>
                    <ChildContent>
                        @I18n.T("Setting.ChatGptAvatar.Hint")
                    </ChildContent>
                </MTooltip>
            </MCol>
            <MCol Cols="12">
                <MSelect @bind-Value="ChatGptOptions.ShortcutKey"
                         Items="_items"
                         Label="@I18n.T("Setting.ShortcutKey.Label")"
                         ItemValue="GetShortcutKey"
                         ItemText="r=>r"
                          >
                </MSelect>
            </MCol>

        </MRow>
    </ChildContent>
</PModal>